#!/bin/bash
##这是为服务安装一条路服务的脚本整合

#最小化实现Docker安装
mirrors-selects(){
    if [[ "$source_select" == 'y' || "$source_select" == 'Y' ]];then
        source_menu-mirrors-select "$1" "$2"
    fi
}
install_menu_install-docker-ce-mini(){
    service_chek 'docker' 
    source_${Package_managements}_bak #检测源备份

    mirrors-selects  "系统源" "mirrors_os"
    mirrors-selects  "Docker源" "mirrors_docker"
    if [[ "$Package_managements" == 'apt' ]];then
        source_${Package_managements}_${System_Type}
    else
        source_${Package_managements}_${System_Type}${System_version}
    fi
    source_${Package_managements}_docker-ce 

    
    install_docker-ce_install-docker #安装Docker
    
    install_docker-ce_docker-config #配置Docker
}

#最小化实现K8S安装
install_menu_install-k8s-mini(){

    service_chek 'kubeadm kubelet kubectl'
    
    source_${Package_managements}_bak #检测源备份

    #获取用户选择的镜像站,一参是备注，二参是设置一个变量名
    mirrors-select "系统源" "mirrors_os"
    mirrors-select "配置K8S源"   "mirrors_k8s"


    source_${Package_managements}_${System_Type}${source_version} #配置系统源

    source_${Package_managements}_k8s #配置K8S源


    install_k8s_install-k8s #安装K8S
    
    install_k8s_install-bash-completion #安装自动补全工具


}
install_menu_install-docker-ce_k8s(){
    source_${Package_managements}_bak #检测源备份
  
    source_${Package_managements}_${System_Type}${source_version} #配置系统源
    #配置Docker源
    if [[ "${Package_management}" -eq 'yum' ]];then
        source_yum_docker-ce
    elif [[ "${Package_management}" -eq 'apt' ]];then
        green_zt "当前系统无需单独配置源"
    else
        red_bg "无法获取当前系统采用的包管理器"
        exit 11
    fi
    source_${Package_managements}_k8s #配置K8S源
    
    install_docker-ce_install-docker #安装Docker
   
    install_docker-ce_docker-config #配置Docker

    install_k8s_install-k8s #安装K8S
    
    install_k8s_install-bash-completion #安装自动补全工具


}
#完成初始的数据库服务安装
install_menu-mariadb-install(){
    service_chek 'mariadb-server' #检测是否已经安装该服务

    install_mariadb-info-set #设置/检查安装信息

    source_${Package_managements}_bak #检测源备份
  
    source_${Package_managements}_${System_Type}${source_version}   #配置系统源

    source_menu-mariadb_version-select #选择Mariadb源版本

    source_mariadb-${Package_managements} #配置Mariadb源

    install_mariadb-install #安装服务

    install_mariadb-init #初始化数据库
}
